﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.MODEL.Statistics;
namespace MINERP.Statistics
{
    public partial class FrmSetBill : Form
    {
        //属性
        public List<Bill_Info> ListBill { get; set; }
        public FrmBill fb { get; set; }
        public FrmSetBill()
        {
            InitializeComponent();
        }

        private void FrmSetBill_Load(object sender, EventArgs e)
        {
            BindBill();
        }
        private void BindBill()
        {
            gcSetBill.DataSource = ListBill;
        }
        
        //全选操作
        private void tsSelectAll_Click(object sender, EventArgs e)
        {
            foreach (Bill_Info b in ListBill)
            {
                b.IsChecked = true;
            }
            gcSetBill.RefreshDataSource();

        }

        // 全不选操作
        private void tsNoSelect_Click(object sender, EventArgs e)
        {
            foreach (Bill_Info b in ListBill)
            {
                b.IsChecked = false;
            }
            gcSetBill.RefreshDataSource();
        }

        //提交选中的账单
        private void tsSelect_Click(object sender, EventArgs e)
        {
            List<Bill_Info> FilterBill = new List<Bill_Info>();
            foreach (Bill_Info b in ListBill)
            {
                if (b.IsChecked == true)
                    FilterBill.Add(b);
            }
            fb.FilterBill = FilterBill;
            this.Close();
        }

        private void gvSetBill_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {

        }

        private void gvSetBill_CellValueChanging(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            Bill_Info bi = gvSetBill.GetRow(e.RowHandle) as Bill_Info;
            if (Convert.ToBoolean(e.Value) == true)
            {
                bi.IsChecked = true;
            }
            else
            {
                bi.IsChecked = false;  
            }
        }
    }
}
